<script setup lang="ts">
import { Fold } from '@element-plus/icons-vue';
import UiBreadcrumb from './breadcrumb.vue'
import UiThemeSwitch from './theme-switch.vue'

const props = defineProps<{ fold?: boolean }>()

const emit = defineEmits<{ 'update:fold': [e: boolean] }>()

const toggleFold = () => emit('update:fold', !props.fold)

const cls = 'ui-layout-header'
</script>

<template>
  <header :class="cls">
    <ElButton
      :class="[`${cls}_fold`, { 'is-fold': fold }]"
      :icon="Fold"
      link
      @click="toggleFold" />
    <UiBreadcrumb />
    <div :class="`${cls}_spring`"></div>
    <div :class="`${cls}_right`">
      <UiThemeSwitch />
    </div>
  </header>
</template>

<style lang="scss">
.ui-layout-header {
  height: var(--header-height);
  padding: 0 12px;
  display: flex;
  align-items: center;
  background-color: var(--el-bg-color);
  border-bottom: 1px solid var(--el-border-color-light);
  &_fold {
    font-size: 20px;
    margin-right: 10px;
    &.is-fold {
      transform: rotate(180deg);
    }
  }
  &_spring {
    flex: 1;
    width: 0;
  }
}
</style>
